#include "stdafx.h"
#include "InlineHook.h"
#include "Windows.h"


bool InlineHook(LPVOID src_addr, LPVOID jmp_addr)
{
	JMPCODE jcode;
    jcode.jmp = 0xe9;//jmp
    jcode.addr = (uintptr_t)jmp_addr - (uintptr_t)src_addr - 5; 
	
	DWORD dwOldProtect, dwTemp;
	::VirtualProtect( (LPVOID)src_addr, 5,PAGE_EXECUTE_READWRITE, &dwOldProtect );
	::WriteProcessMemory(GetCurrentProcess(),src_addr, &jcode, sizeof(JMPCODE), NULL);
	::VirtualProtect( (LPVOID)src_addr, 5,dwOldProtect, &dwTemp); 
	return true;
}